package com.example.baseapp.controller;

import com.example.baseapp.common.ApiResponse;
import com.example.baseapp.entity.Dish;
import com.example.baseapp.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/dish")
public class DishController {
    
    @Autowired
    private DishService dishService;
    
    // 获取所有菜品
    @PostMapping("/list")
    public ApiResponse<List<Dish>> getAllDishes(@RequestBody(required = false) Map<String, Object> params) {
        return ApiResponse.success(dishService.getAllDishes());
    }
    
    // 根据分类获取菜品
    @PostMapping("/listByCategory")
    public ApiResponse<List<Dish>> getDishesByCategory(@RequestBody Map<String, Object> params) {
        Long categoryId = Long.valueOf(params.get("categoryId").toString());
        return ApiResponse.success(dishService.getDishesByCategory(categoryId));
    }
} 